package xyz.hlh.boot1.controller;

import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import xyz.hlh.boot1.service.GoodsService;

/**
 * @author HLH
 * @description: 商品控制层
 * @email 17703595860@163.com
 * @date : Created in 2021/10/30 21:07
 */
@Controller // 同步 使用thymeleaf模板引擎
public class GoodsController {

    // 注入dubbo服务
    // url：直连，没有注册中心，所以使用url直接指定服务的地址
    @DubboReference(interfaceClass = GoodsService.class, url = "dubbo://localhost:20880")
    private GoodsService goodsService;

    @GetMapping("/goods/list")
    public String toList(Model model) {
        model.addAttribute("goods", goodsService.getList());
        return "goods";
    }

}
